#region Copyright RenGuiYou. All rights reserved.
//=====================================================
// NeatlyFrameWork
// Author:      RenGuiyou
// Feedback: 	mailto:750539605@qq.com
//=====================================================
#endregion
using Neatly.UI;
using UnityEditor;
using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine.UI;

namespace NeatlyEditor.UI
{
    [CustomEditor(typeof(NSlider), true)]
    [CanEditMultipleObjects]
    public class NSliderEditor : Editor
    {
        #region SerializedProperty
        SerializedProperty m_Direction;
        SerializedProperty m_FillRect;
        SerializedProperty m_HasBar;
        SerializedProperty m_StartBorder;
        SerializedProperty m_EndBorder;
        SerializedProperty m_Value;
        #endregion

        protected virtual void OnEnable()
        {
            m_HasBar = serializedObject.FindProperty("m_HasBar");
            m_StartBorder = serializedObject.FindProperty("m_StartBorder");
            m_EndBorder = serializedObject.FindProperty("m_EndBorder");
            m_Direction = serializedObject.FindProperty("m_Direction");
            m_FillRect = serializedObject.FindProperty("m_FillRect");
            m_Value = serializedObject.FindProperty("m_Value");
        }
        
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUILayout.PropertyField(m_Direction);
            EditorGUILayout.PropertyField(m_FillRect);
            EditorGUILayout.PropertyField(m_Value);
            OnBarSettingGUI();
            serializedObject.ApplyModifiedProperties();
        }

        private void OnBarSettingGUI()
        {
            EditorGUILayout.PropertyField(m_HasBar);
            if (m_HasBar.boolValue)
            {
                ++EditorGUI.indentLevel;
                EditorGUILayout.PropertyField(m_StartBorder);
                EditorGUILayout.PropertyField(m_EndBorder);
                --EditorGUI.indentLevel;
            }
        }
    }
}
